<template>
  <div class="chart-container">
    <div class="chart-box">
      <chart :series-data="seriesData" height="100%" width="100%" />
    </div>
  </div>
</template>

<script>
import Chart from '@/components/Charts/LineTime' //

export default {
  name: 'LineChart',
  components: { Chart },
  data() {
    return {
      seriesData: [
        {
          name: 'CMCC',
          data: [[1522306819000, 120], [1522306919000, 110], [1522307019000, 125], [1522307119000, 145]]
        }
        // {  可以有多条数据
        //     name: "CTCC",
        //     data: [120, 110]
        // },

      ],
      num: [100, 150, 200]
    }
  },
  mounted() {
    this.updataData()
  },
  methods: {
    updataData() {
      setInterval(() => {
        // this.seriesData[0].data.shift();
        const n = parseInt(Math.random() * 1000000)
        const time = this.seriesData[0].data[this.seriesData[0].data.length - 1][0]
        this.seriesData[0].data.push([time + n, 145 + n / 1000])
      }, 1000)
    }
  }
}
</script>

<style scoped>
.chart-container {
    position: relative;
    width: 100%;
    height: 100%;
}
.chart-box {
    width: 100%;
    height: 100%;
    padding: 15px;
    box-sizing: border-box;
    border-radius: 4px;
    background: #fff;
}
</style>

